
def select_sort(nums):

    for j in range(len(nums)-1):
        min_index = j
        i = j+1
        while i < len(nums):
            if nums[i] < nums[min_index]:
                min_index = i
            i += 1
        if min_index != j:
            nums[j],nums[min_index] = nums[min_index],nums[j]
    return nums

'''
时间复杂度：最优、最坏：O(n^2)
稳定性：不稳定
'''
print(select_sort([5,4,3,2,1,0]))

